# -*- coding: utf-8 -*-

from PySide.QtGui import *
from PySide.QtCore import *
import sys

QTextCodec.setCodecForTr(QTextCodec.codecForName("utf8"))

class MyTable(QTableWidget):
    def __init__(self,parent=None):
        super(MyTable, self).__init__(parent)
        #列
        self.setColumnCount(5)
        #行数
        self.setRowCount(2)
        self.setItem(0,0,QTableWidgetItem(self.tr("性别")))
        self.setItem(0,1,QTableWidgetItem(self.tr("姓名")))
        self.setItem(0,2,QTableWidgetItem(self.tr("出生日期")))
        self.setItem(0,3,QTableWidgetItem(self.tr("职业")))
        self.setItem(0,4,QTableWidgetItem(self.tr("收入")))
        #标签
        lbp1=QLabel()
        #图片
        lbp1.setPixmap(QPixmap("img/tx1.jpg"))
        #格
        self.setCellWidget(1,0,lbp1)
        twi1=QTableWidgetItem("Tom")
        self.setItem(1,1,twi1)
        #可修改时间
        date1=QDateTimeEdit()
        date1.setDateTime(QDateTime.currentDateTime())
        date1.setDisplayFormat("yyyy/mm/dd")
        date1.setCalendarPopup(True)
        self.setCellWidget(1,2,date1)
        #下拉框
        cbw=QComboBox()
        cbw.addItem("Worker")
        cbw.addItem("Famer")
        cbw.addItem("Doctoer")
        cbw.addItem("Lawyer")
        cbw.addItem("Soldier")
        self.setCellWidget(1,3,cbw)
        sb1=QSpinBox()
        sb1.setRange(1000,10000)
        self.setCellWidget(1,4,sb1)

if __name__ =="__main__":
    app=QApplication(sys.argv)
    mytable=MyTable()
    mytable.setWindowTitle("My Table")
    mytable.show()
    sys.exit(app.exec_())